﻿using System;
using System.Web.UI.WebControls;
using BLL;
using Model;

public partial class StatisticData_PercentPoint_PPbyPID_Day : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCustoms();
            BindProductTypes();
        }
    }

    protected void BindCustoms()
    {
        Customer cust = new Customer();
        this.DropDownList1.DataSource = cust.LoadEntities();
        this.DropDownList1.DataTextField = "CustomerName";
        this.DropDownList1.DataValueField = "CustomerID";
        this.DropDownList1.DataBind();
    }

    protected void BindProductTypes()
    {
        ProductType pt = new ProductType();
        this.DropDownList2.DataSource = pt.GetProductTypesbyCustomerID(this.DropDownList1.SelectedValue);
        this.DropDownList2.DataTextField = "ProductTypeName";
        this.DropDownList2.DataValueField = "ProductTypeID";
        this.DropDownList2.DataBind();
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindProductTypes();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        BindPP();
    }

    protected void BindPP()
    {
        TestItem_PP pp = new TestItem_PP();
        string var_productTypeID = this.DropDownList2.SelectedValue;
        DateTime var_time = DateTime.Parse(this.TextBox2.Text + " 00:00:00");
        string time = var_time.Year.ToString("00") + var_time.Month.ToString("00") + var_time.Day.ToString("00");
        this.GridView1.DataSource = pp.GetDayPID_PP(var_productTypeID, time);
        this.GridView1.DataBind();
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindPP();
    }
}
